package geppetto.cat.analysis;

import geppetto.cat.corpus.BilingualCorpus;
import gnu.trove.TIntArrayList;

import java.io.PrintStream;



public class AlignmentError {
	int _wordId;

	int _wordPosition;

	int _supposedWord;

	int _supposedWordPosition;

	TIntArrayList _sure;

	TIntArrayList _surePositions;

	TIntArrayList _possible;

	TIntArrayList _possiblePositions;

	public AlignmentError(int wordId, int wordPosition, int supposedWord,
			int supposedWordPosition, TIntArrayList sure,
			TIntArrayList surePositions, TIntArrayList possible,
			TIntArrayList possiblePositions) {
		_wordId = wordId;
		_wordPosition = wordPosition;
		_supposedWord = supposedWord;
		_supposedWordPosition = supposedWordPosition;
		_sure = sure;
		_surePositions = surePositions;
		_possible = possible;
		_possiblePositions = possiblePositions;
	}

	public void output(BilingualCorpus corpus, PrintStream out) {
		out.print(corpus.getForeignWordById(_wordId) + "(" + _wordPosition
				+ ")");
		if (_supposedWord == -1) {
			out.print(" --> null ");
		} else {
			out.print(" --> " + corpus.getSourceWordById(_supposedWord) + "("
					+ _supposedWordPosition + ")");
		}
		if (_sure.size() > 0) {
			out.print(" S--> ");
			for (int i = 0; i < _sure.size(); i++) {
				out.print(corpus.getSourceWordById(_sure.get(i)) + "("
						+ _surePositions.get(i) + ") ");
			}
		}
		if (_possible.size() > 0) {
			out.print(" P--> ");
			for (int i = 0; i < _possible.size(); i++) {
				out.print(corpus.getSourceWordById(_possible.get(i)) + "("
						+ _possiblePositions.get(i) + ") ");
			}
		}
		out.println("");
	}

}
